<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="ID">
            <el-input v-model="form.id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品SKU_ID" prop="skuId">
            <el-input v-model="form.skuId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="变更时间" prop="changeTime">
            <el-input v-model="form.changeTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="上市时间" prop="addTime">
            <el-input v-model="form.addTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="退市时间" prop="outTime">
            <el-input v-model="form.outTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="价格有效时间" prop="effeTime">
            <el-input v-model="form.effeTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="一级供货价(元)" prop="firstSourcePrice">
            <el-input v-model="form.firstSourcePrice" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="一级售价(元)" prop="firstSalePrice">
            <el-input v-model="form.firstSalePrice" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="二级供货价(元)" prop="secondSourcePrice">
            <el-input v-model="form.secondSourcePrice" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="二级售价(元)" prop="secondSalePrice">
            <el-input v-model="form.secondSalePrice" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="三级供货价(元)" prop="thridSourcePrice">
            <el-input v-model="form.thridSourcePrice" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="三级售价(元)" prop="thridSalePrice">
            <el-input v-model="form.thridSalePrice" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="零售供货价(元)" prop="sourcePrice">
            <el-input v-model="form.sourcePrice" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="零售售价(元)" prop="salePrice">
            <el-input v-model="form.salePrice" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否删除 0：否 1：是" prop="isDel">
            <el-input v-model="form.isDel" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建时间" prop="createTime">
            <el-input v-model="form.createTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建人" prop="createUser">
            <el-input v-model="form.createUser" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column v-if="columns.visible('id')" prop="id" label="ID" />
        <el-table-column v-if="columns.visible('skuId')" prop="skuId" label="商品SKU_ID" />
        <el-table-column v-if="columns.visible('changeTime')" prop="changeTime" label="变更时间" />
        <el-table-column v-if="columns.visible('addTime')" prop="addTime" label="上市时间" />
        <el-table-column v-if="columns.visible('outTime')" prop="outTime" label="退市时间" />
        <el-table-column v-if="columns.visible('effeTime')" prop="effeTime" label="价格有效时间" />
        <el-table-column v-if="columns.visible('firstSourcePrice')" prop="firstSourcePrice" label="一级供货价(元)" />
        <el-table-column v-if="columns.visible('firstSalePrice')" prop="firstSalePrice" label="一级售价(元)" />
        <el-table-column v-if="columns.visible('secondSourcePrice')" prop="secondSourcePrice" label="二级供货价(元)" />
        <el-table-column v-if="columns.visible('secondSalePrice')" prop="secondSalePrice" label="二级售价(元)" />
        <el-table-column v-if="columns.visible('thridSourcePrice')" prop="thridSourcePrice" label="三级供货价(元)" />
        <el-table-column v-if="columns.visible('thridSalePrice')" prop="thridSalePrice" label="三级售价(元)" />
        <el-table-column v-if="columns.visible('sourcePrice')" prop="sourcePrice" label="零售供货价(元)" />
        <el-table-column v-if="columns.visible('salePrice')" prop="salePrice" label="零售售价(元)" />
        <el-table-column v-if="columns.visible('isDel')" prop="isDel" label="是否删除 0：否 1：是" />
        <el-table-column v-if="columns.visible('createTime')" prop="createTime" label="创建时间" />
        <el-table-column v-if="columns.visible('createUser')" prop="createUser" label="创建人" />
        <el-table-column v-permission="['admin','supplierGoodsSkuLog:edit','supplierGoodsSkuLog:del']" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudSupplierGoodsSkuLog from '@/api/supplier/supplierGoodsSkuLog'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

// crud交由presenter持有
const defaultCrud = CRUD({ title: '商品修改日志', url: 'api/supplierGoodsSkuLog', sort: 'id,desc', crudMethod: { ...crudSupplierGoodsSkuLog }})
const defaultForm = { id: null, skuId: null, changeTime: null, addTime: null, outTime: null, effeTime: null, firstSourcePrice: null, firstSalePrice: null, secondSourcePrice: null, secondSalePrice: null, thridSourcePrice: null, thridSalePrice: null, sourcePrice: null, salePrice: null, isDel: null, createTime: null, createUser: null }
export default {
  name: 'SupplierGoodsSkuLog',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  data() {
    return {
      permission: {
        add: ['admin', 'supplierGoodsSkuLog:add'],
        edit: ['admin', 'supplierGoodsSkuLog:edit'],
        del: ['admin', 'supplierGoodsSkuLog:del']
      },
      rules: {
        skuId: [
          { required: true, message: '商品SKU_ID不能为空', trigger: 'blur' }
        ],
        changeTime: [
          { required: true, message: '变更时间不能为空', trigger: 'blur' }
        ],
        addTime: [
          { required: true, message: '上市时间不能为空', trigger: 'blur' }
        ],
        outTime: [
          { required: true, message: '退市时间不能为空', trigger: 'blur' }
        ],
        effeTime: [
          { required: true, message: '价格有效时间不能为空', trigger: 'blur' }
        ],
        firstSourcePrice: [
          { required: true, message: '一级供货价(元)不能为空', trigger: 'blur' }
        ],
        firstSalePrice: [
          { required: true, message: '一级售价(元)不能为空', trigger: 'blur' }
        ],
        secondSourcePrice: [
          { required: true, message: '二级供货价(元)不能为空', trigger: 'blur' }
        ],
        secondSalePrice: [
          { required: true, message: '二级售价(元)不能为空', trigger: 'blur' }
        ],
        thridSourcePrice: [
          { required: true, message: '三级供货价(元)不能为空', trigger: 'blur' }
        ],
        thridSalePrice: [
          { required: true, message: '三级售价(元)不能为空', trigger: 'blur' }
        ],
        sourcePrice: [
          { required: true, message: '零售供货价(元)不能为空', trigger: 'blur' }
        ],
        salePrice: [
          { required: true, message: '零售售价(元)不能为空', trigger: 'blur' }
        ],
        isDel: [
          { required: true, message: '是否删除 0：否 1：是不能为空', trigger: 'blur' }
        ],
        createTime: [
          { required: true, message: '创建时间不能为空', trigger: 'blur' }
        ],
        createUser: [
          { required: true, message: '创建人不能为空', trigger: 'blur' }
        ]
      }}
  },
  methods: {
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
